package win.smartown.android.base

import android.os.Bundle
import android.support.annotation.IdRes
import android.support.annotation.LayoutRes
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import win.smartown.android.base.loading.LoadingActivity

/**
 * Created by smartown on 2017/3/19.
 * <br></br>
 * Description:
 */
open class BaseFragment : Fragment() {

    private var content: View? = null

    fun setConten(@LayoutRes layoutId: Int) {
        content = LayoutInflater.from(activity).inflate(layoutId, null)
    }

    override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
        return content
    }

    protected fun <T : View> findView(@IdRes id: Int): T {
        return content!!.findViewById(id) as T
    }

    protected val superActivity: SuperActivity
        get() = activity as SuperActivity

    protected val baseActivity: BaseActivity
        get() = activity as BaseActivity

    protected val loadingActivity: LoadingActivity
        get() = activity as LoadingActivity

}
